package cn.chenfeifx.core.controls;

import cn.chenfeifx.core.controls.skins.CFCarouselSkin;
import cn.chenfeifx.core.common.ResourcesLoader;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.ObservableList;
import javafx.scene.control.Control;
import javafx.scene.image.ImageView;

public class CFCarousel extends Control {

    private static final String STYLE_SHEET = ResourcesLoader.load("/cn/chenfeifx/core/css/cf-carousel.css");
    private static final String STYLE_CLASS = "cf-carousel";
    private ListProperty<ImageView> imageViews = new SimpleListProperty<>();

    public CFCarousel(ObservableList<ImageView> imageViews) {
        this.imageViews.set(imageViews);
        initialize();
    }

    private void initialize() {
        setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
        getStyleClass().add(STYLE_CLASS);
    }

    public ObservableList<ImageView> getImageViews() {
        return imageViews.get();
    }

    public void setImageViews(ObservableList<ImageView> imageViews) {
        this.imageViews.set(imageViews);
    }

    public ListProperty<ImageView> imageViewsProperty() {
        return imageViews;
    }

    @Override
    protected CFCarouselSkin createDefaultSkin() {
        return new CFCarouselSkin(this);
    }

    @Override
    public String getUserAgentStylesheet() {
        return STYLE_SHEET;
    }

}
